<?php


namespace app\api\controller;


use app\api\model\NotesModel;
use app\api\validate\NotesValidate;

class Notes extends ApiBase
{

    /**
     *
     * 保存会议笔记
     */
    public function notesAdd(NotesValidate $request){

        $params = $this->request->post();
        $params['user_id'] = $this->id;
        $params['type'] = isset($params['type']) ? $params['type'] : 0;
        if ($params['type'] == 0){

            $scene = 'notesExpertAdd';
        }else{

            $scene = 'notesAIAdd';
        }
        if (!$request->scene($scene)->check($params)){

            $this->fail($request->getError());
        }
        $res = NotesModel::notesAdd($params);
        if ($res){

            $this->successful('操作成功');
        }else{

            $this->fail('操作失败');
        }
    }

    /**
     *
     * 会议笔记信息
     */
    public function notesInfo(){
        $params = $this->request->get();
        $params['type'] = isset($params['type']) ? $params['type'] : 0;
        if (!isset($params['id']) || empty($params['id'])){

            $this->fail('缺少病例id');
        }
        $data = NotesModel::notesInfo($params);
        $this->successful('查询成功',$data);
    }
}